package com.winner.strategy_pattern.phoneplan;

import org.springframework.stereotype.Service;

@Service
public class SaveNumberServiceImpl implements PhonePlanStrategy {

    @Override
    public double doOperation(int talkTime, int flow) {
        int exceedFlow = flow <= 100 ? 0 : (flow - 100);
        double result = 10 + 0.2 * talkTime + 0.1 * exceedFlow;
        System.out.println("使用保号套餐资费为: " + result);
        return result;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        PhonePlanFactory.register("SAVE_NUMBER", this);
    }
}
